home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
PRG
/
MacPerl 506 appl folder.sit
/
MacPerl 506 appl folder
/
Mac_Perl_506r1m_appl
/
lib
/
shellwords.pl
< prev
next >
Wrap
Text File
|
1994-12-26
|
880b
|
49 lines
;# shellwords.pl
;#
;# Usage:
;# require 'shellwords.pl';
;# @words = &shellwords($line);
;# or
;# @words = &shellwords(@lines);
;# or
;# @words = &shellwords; # defaults to $_ (and clobbers it)
sub shellwords {
package shellwords;
local($_) = join('', @_) if @_;
local(@words,$snippet,$field);
s/^¥s+//;
while ($_ ne '') {
$field = '';
for (;;) {
if (s/^"(([^"¥¥]|¥¥.)*)"//) {
($snippet = $1) =~ s#¥¥(.)#$1#g;
}
elsif (/^"/) {
die "Unmatched double quote: $_¥n";
}
elsif (s/^'(([^'¥¥]|¥¥.)*)'//) {
($snippet = $1) =~ s#¥¥(.)#$1#g;
}
elsif (/^'/) {
die "Unmatched single quote: $_¥n";
}
elsif (s/^¥¥(.)//) {
$snippet = $1;
}
elsif (s/^([^¥s¥¥'"]+)//) {
$snippet = $1;
}
else {
s/^¥s+//;
last;
}
$field .= $snippet;
}
push(@words, $field);
}
@words;
}
1;